package com.project.controller;

import com.project.bean.SellCarBean;
import com.project.service.ISellCarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("sellCar")
public class SellCarController {
    @Autowired
    private ISellCarService sellCarService;

    @RequestMapping("findByUserId")
    public List<SellCarBean> findByUserId(Integer userId){

        return sellCarService.findByUserId(userId);
    }
    @RequestMapping("add")
    public String add(String productId, Integer userId){

        sellCarService.add(productId, userId);
        return "ok";
    }
    @RequestMapping("update")
    public String update(Integer sellCarId, Integer num){
        sellCarService.update(sellCarId,num);
        return "ok";
    }
    @RequestMapping("del")
    public String del(Integer sellCarId){
        sellCarService.del(sellCarId);
        return "ok";
    }
    @RequestMapping("getTotalPrice")
    public Integer getTotalPrice(Integer userId){
        return sellCarService.getTotalPrice(userId);
    }
}
